package cn.ourpk.robot.blog;

import java.io.IOException;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;

import org.apache.commons.httpclient.HttpException;

import cn.ourpk.bbs.robot.service.Page;
import cn.ourpk.bbs.robot.service.RobotService;
import cn.ourpk.bbs.robot.service.Site;

public class RobotBlog {

	private static final String username = "robot";
	private static final String password = "Passw0rd";
	private static final String target_login = "_ctl0:bcr:Login1:_:loginButton";
	private static final String target_publish = "_ctl0:_ctl0:TaskRegion:Editor1:PostButton";
	private static final String argument = "";
	private static final String login_viewstate = "dDwtNzcwOTgwOTMwOztsPF9jdGwwOmJoY3I6dDpfOlRpdGxlQmFyU2VhcmNoVGV4dDtfY3RsMDpiY3I6TG9naW4xOl86dXNlcm5hbWU7X2N0bDA6YmNyOkxvZ2luMTpfOnBhc3N3b3JkO19jdGwwOmJjcjpMb2dpbjE6XzphdXRvTG9naW47Pj4+VOLzNX5sZeeqQHzFTXyA/VqK4g==";
	private static final String post_viewstate = "dDwxODM5NDk5MjMwO3Q8O2w8aTwyPjs+O2w8dDw7bDxpPDA+Oz47bDx0PDtsPGk8Mj47PjtsPHQ8O2w8aTwwPjs+O2w8dDw7bDxpPDEzPjs+O2w8dDw7bDxpPDc+O2k8MTM+O2k8MTc+O2k8MTk+Oz47bDx0PDtsPGk8MD47PjtsPHQ8O2w8aTwxPjtpPDU+Oz47bDx0PDtsPGk8MD47PjtsPHQ8O2w8aTwxPjs+O2w8dDw7bDxpPDA+Oz47bDx0PDtsPGk8MD47aTwyPjs+O2w8dDxwPGw8VGV4dDs+O2w8U2lnbmVkIGluIGFzIFw8YSBocmVmPSIvQ0NTL3VzZXIvRWRpdFByb2ZpbGUuYXNweD9SZXR1cm5Vcmw9L0NDUy9Db250cm9sUGFuZWwvQmxvZ3MvcG9zdGVkaXRvci5hc3B4P1NlbGVjdGVkTmF2SXRlbT1OZXdQb3N0Ilw+a2FuZVw8L2FcPjs+Pjs7Pjt0PHA8bDxWaXNpYmxlOz47bDxvPHQ+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q8O2w8aTwxPjs+O2w8dDw7bDxpPDE+Oz47bDx0PHQ8OztsPGk8MD47Pj47Oz47Pj47Pj47dDw7bDxpPDE+Oz47bDx0PDtsPGk8MT47PjtsPHQ8dDw7O2w8aTwwPjs+Pjs7Pjs+Pjs+Pjt0PDtsPGk8MT47PjtsPHQ8O2w8aTwxPjs+O2w8dDx0PDs7bDxpPDE+Oz4+Ozs+Oz4+Oz4+O3Q8cDxsPFZpc2libGU7PjtsPG88Zj47Pj47bDxpPDE+Oz47bDx0PDtsPGk8MT47PjtsPHQ8dDw7O2w8aTwxPjs+Pjs7Pjs+Pjs+Pjs+Pjs+Pjs+Pjs+Pjt0PHA8cDxsPEVuYWJsZWQ7PjtsPG88Zj47Pj47Pjs7Pjt0PHA8cDxsPFRleHQ7PjtsPFNhdmUgYW5kIENvbnRpbnVlIFdyaXRpbmc7Pj47cDxsPG9uY2xpY2s7PjtsPGJ5cGFzc0NoZWNrKClcOzs+Pj47Oz47dDxwPHA8bDxUZXh0Oz47bDxTYXZlLCBidXQgZG9uJ3QgUHVibGlzaDs+PjtwPGw8b25jbGljazs+O2w8YnlwYXNzQ2hlY2soKVw7Oz4+Pjs7Pjt0PHA8cDxsPFRleHQ7PjtsPFB1Ymxpc2g7Pj47cDxsPG9uY2xpY2s7PjtsPGJ5cGFzc0NoZWNrKClcOzs+Pj47Oz47Pj47Pj47Pj47Pj47Pj47Pj47Pj47Pj47Pj47bDxfY3RsMDpfY3RsMDpQYW5lbFRhYnM6XzpUYWJTdHJpcDtfY3RsMDpfY3RsMDpUYXNrUmVnaW9uOkVkaXRvcjE6RWRpdG9yVGFicztfY3RsMDpfY3RsMDpUYXNrUmVnaW9uOkVkaXRvcjE6RGF0ZVBpY2tlcjs+Pnm/iXC9AFxKVyjnpNqxzmY1QZi+";
	private static final String[] MONTHS = new String[]{"一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"};
	private Site site;
	
	public void doLogin(){
		site = findById("ourpk");
		try {
			site.login(target_login, argument, login_viewstate, username, password);
		} catch (HttpException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	public void post(String subject, String content, Date pubDate){
		Page[] pages = site.getPages();
		if(pages.length > 0){
			try {
				Calendar cal = GregorianCalendar.getInstance();
				cal.setTime(pubDate);
				String date = MONTHS[cal.get(Calendar.MONTH)] + "  " + cal.get(Calendar.DAY_OF_MONTH) + " " + cal.get(Calendar.YEAR);
				pages[0].execute(target_publish, argument, post_viewstate, new String(subject.getBytes("UTF-8"), "ISO-8859-1"), 
						new String(content.getBytes("UTF-8"), "ISO-8859-1"), new String(date.getBytes("UTF-8"), "ISO-8859-1"), 
						String.valueOf(cal.get(Calendar.HOUR)), String.valueOf(cal.get(Calendar.MINUTE)), 
						(Calendar.AM == cal.get(Calendar.AM_PM) ? "AM" : "PM"));
			} catch (HttpException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
	}
	
	private Site findById(String id){
		Site site = null;
		RobotService service = Activator.getInstance().getRobotService();
		Site[] sites = service.getSites();
		for(int i = 0; i < sites.length; i++){
			if(sites[i].getId().equals(id)){
				site = sites[i];
				break;
			}
		}
		return site;
	}
}
